package com.jf.blog_jf04.utils.interceptor;

import com.jf.blog_jf04.bean.Userinfo;
import com.jf.blog_jf04.utils.LoginUtils;
import com.jf.blog_jf04.utils.MyConstants;
import com.jf.blog_jf04.utils.exception.BusinessException;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

@Component
public class UserinfoStatusInterceptor implements HandlerInterceptor {
    @Override
    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        Userinfo login = LoginUtils.getLoginUserinfo();
        if (login.getUserinfoStatus() != MyConstants.USERINFO_YIRENZHENG) {
            throw new BusinessException("请先进行实名认证！");
        }
        return true;
    }
}
